//
//  BlHotleOrderTableViewCell.m
//  blanket
//
//  Created by Mac on 2018/11/15.
//  Copyright © 2018 stoneobs@icloud.com. All rights reserved.
//

#import "BlHotleOrderTableViewCell.h"

@interface  BlHotleOrderTableViewCell()
@property(nonatomic, strong) UIImageView                     *bannerImagView;/**< <##> */
@property(nonatomic, strong) STLabel                     *statusLable;/**<  */
@property(nonatomic, strong) STLabel                     *nameLable;/**<  */


@property(nonatomic, strong) STLabel                     *downOrderTimeLable;/**<  */
@property(nonatomic, strong) STLabel                     *orderNumLable;/**<  */
@property(nonatomic, strong) STLabel                     *desLable;/**<  */
@property(nonatomic, strong) STLabel                     *inTimeLable;/**<  */
@property(nonatomic, strong) STLabel                     *allLable;/**<  */
@property(nonatomic, strong) STLabel                     *userLable;/**<  */
@property(nonatomic, strong) STLabel                     *codeLable;/**<  */
@property(nonatomic, strong) STLabel                     *phoneLable;/**<  */

@end
@implementation BlHotleOrderTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self == [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self configSubView];
    }
    return self;
}
+ (CGFloat)cellHeight{
    return 275;
}
#pragma mark --subView
- (void)configSubView{
    UIImageView * imageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 76, 76)];
    imageView.image = [UIImage imageNamed:@""];
    [self addSubview:imageView];
    self.bannerImagView = imageView;
    
    self.nameLable = [[STLabel alloc] initWithFrame:CGRectMake(0, 10, 100, 40)
                                                 text:@""
                                            textColor:FirstTextColor
                                                 font:15
                                          isSizetoFit:NO
                                        textAlignment:NSTextAlignmentLeft];
    self.nameLable.left = imageView.right +  10;
    [self addSubview:self.nameLable];
    
    self.statusLable = [[STLabel alloc] initWithFrame:CGRectMake(0, 10, 100, 40)
                                                     text:@"已完成"
                                                textColor:FlatBlue
                                                     font:14
                                              isSizetoFit:NO
                                            textAlignment:NSTextAlignmentRight];
    self.statusLable.right = UIScreenWidth - 10;
    [self addSubview:self.statusLable];
    
    CGFloat top = self.nameLable.bottom;
    ({
        STLabel * lable = [self deflutLable];
        lable.top = top;
        self.downOrderTimeLable = lable;
        top = lable.bottom;
        [self addSubview:lable];
    });
    
    ({
        STLabel * lable = [self deflutLable];
        lable.top = top;
        self.orderNumLable = lable;
        top = lable.bottom;
        [self addSubview:lable];
    });
    
    ({
        STLabel * lable = [self deflutLable];
        lable.top = top;
        self.desLable = lable;
        top = lable.bottom;
        [self addSubview:lable];
    });
    
    ({
        STLabel * lable = [self deflutLable];
        lable.top = top;
        self.inTimeLable = lable;
        top = lable.bottom;
        [self addSubview:lable];
    });
    ({
        STLabel * lable = [self deflutLable];
        lable.top = top;
        self.allLable = lable;
        top = lable.bottom;
        [self addSubview:lable];
    });
    ({
        STLabel * lable = [self deflutLable];
        lable.top = top;
        self.userLable = lable;
        top = lable.bottom;
        [self addSubview:lable];
    });
    
    ({
        STLabel * lable = [self deflutLable];
        lable.top = top;
        self.codeLable = lable;
        top = lable.bottom;
        [self addSubview:lable];
    });
    
    ({
        STLabel * lable = [self deflutLable];
        lable.top = top + 10;
        self.phoneLable = lable;
        top = lable.bottom;
        [self addSubview:lable];
    });
    
    self.menuButton = [[STButton alloc] initWithFrame:CGRectMake(0, 0, 75, 36)
                                                     title:@"付款"
                                                titleColor:UIColor.whiteColor
                                                 titleFont:15
                                              cornerRadius:18
                                           backgroundColor:FlatRed
                                           backgroundImage:nil
                                                     image:nil];
    self.menuButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
    self.menuButton.right = UIScreenWidth - 15;
    self.menuButton.centerY = self.phoneLable.centerY;
    [self addSubview:self.menuButton];
}
- (STLabel*)deflutLable{
    STLabel * titleLable = [[STLabel alloc] initWithFrame:CGRectMake(self.bannerImagView.right + 10, 0, self.statusLable.left - 20, 25)
                                                     text:@""
                                                textColor:SecendTextColor
                                                     font:14
                                              isSizetoFit:NO
                                            textAlignment:NSTextAlignmentLeft];
    return titleLable;
}
- (void)setModel:(BLHotleOrderModel *)model{
    _model = model;
    [self.bannerImagView sd_setImageWithURL:[NSURL URLWithString:model.img]];
    self.nameLable.text = model.hotel_name;
    self.downOrderTimeLable.text = [NSString stringWithFormat:@"下单时间:%@",model.create_time];
    self.orderNumLable.text = [NSString stringWithFormat:@"订单号:%@",model.order_num];
    self.desLable.text = [NSString stringWithFormat:@"描述:%@间,%@",model.num,model.room_name];
    self.inTimeLable.text = [NSString stringWithFormat:@"入驻时间:%@",model.arrive];
    self.allLable.text = [NSString stringWithFormat:@"总计:%@ * %@  = %0.2f元",model.price,model.num,model.price.floatValue * model.num.integerValue];
    self.userLable.text = [NSString stringWithFormat:@"入住人:%@",model.user_name];
    self.phoneLable.text = [NSString stringWithFormat:@"联系电话:%@",model.phone];
    
    self.menuButton.hidden = NO;
    if (model.status.integerValue  < 2) {

         self.codeLable.text = [NSString stringWithFormat:@"%@",@"(酒店确认后，您将获得可以使用的验证码)"];
    }else{

        self.codeLable.text = [NSString stringWithFormat:@"验证码:%@",model.code];
    }
   
//    订单状态 0=>待付款 1=>已付款 2=>酒店已确认 3=>验证码已确认（已使用） 4=>订单完成 5=>已取消
    if (model.status.integerValue == 0) {
        self.statusLable.text = @"待付款";
        [self.menuButton setTitle:@"付款" forState:UIControlStateNormal];
    }
    if (model.status.integerValue == 1) {
        self.statusLable.text = @"已付款";
        [self.menuButton setTitle:@"联系酒店" forState:UIControlStateNormal];
    }
    if (model.status.integerValue == 2) {
        self.statusLable.text = @"酒店已确认";
        [self.menuButton setTitle:@"联系酒店" forState:UIControlStateNormal];
    }
    if (model.status.integerValue == 3) {
        self.statusLable.text = @"已入住";
        [self.menuButton setTitle:@"删除订单" forState:UIControlStateNormal];
    }
    if (model.status.integerValue == 4) {
        self.statusLable.text = @"已完成";
        [self.menuButton setTitle:@"删除订单" forState:UIControlStateNormal];
        self.menuButton.hidden = YES;
    }
    if (model.status.integerValue == 5) {
        self.statusLable.text = @"已取消";
        [self.menuButton setTitle:@"删除订单" forState:UIControlStateNormal];
    }
}
@end
